import os
import tensorflow as tf
# from tensorflow.keras import Sequential
from keras import Sequential
from keras.layers import Dense

import numpy as np

if __name__ == '__main__':
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
    # 加载要处理的数据集
    dataset = np.genfromtxt("dataset.csv", delimiter=",")
    # print(dataset)

    model = Sequential(
        [
            Dense(units=1, input_shape=[1])
        ]
    )
    model.compile(loss="mean_squared_error")
    model.fit(dataset[:, 0], dataset[:, 1], epochs=1000)

    model.summary()

    print(f"模型权重：{model.layers[0].kernel.numpy().ravel()}")
    print(f"模型偏置：{model.layers[0].bias.numpy()}")
